﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ProjectInputModels>" %>

<%@ Import Namespace="ChoViet.Lib.Helpers" %>
<%@ Import Namespace="ChoViet.Lib.Paging" %>
<%@ Import Namespace="ChoViet.Admin.ViewModels" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Sửa dự án
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%if (ViewData["MessageInfo"] == null)
      { %>

    <script type="text/javascript">
        $(function() {
            $("#projectTabs").tabs();
        });
    </script>

    <div class="projectEdit">
        <div id="projectTabs">
            <ul>
                <li><a href="#projectTabs-1">Thông tin dự án</a></li>
                <li><a href="#projectTabs-2" id="googleTabs">Google Map</a></li>
                <li><a href="#projectTabs-3">Ảnh phối cảnh</a></li>
                <li><a href="#projectTabs-4">Ảnh tiến độ</a></li>
                <li><a href="#projectTabs-5">Ảnh nhà mẫu</a></li>
                <li><a href="#projectTabs-6">Sơ đồ bản vẽ</a></li>
            </ul>
            <% using (Html.BeginForm("Edit", "Project", FormMethod.Post, new
                   {
                       id = "adminForm",
                       enctype = "multipart/form-data"
                   }))
                   {%>
                <%= Html.ValidationSummary(true)%>
            <div id="projectTabs-1">
                
                <table class="admintable" width="100%">
                    <tbody>
                        <tr>
                            <td class="key">
                                Phân mục (<font color="red">*</font>)
                            </td>
                            <td>
                                <%=Html.TreeViewList("Project.CatID", Model.Categories, "-- Chuyên mục --", new { @class = "title required" })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Trạng thái pháp lý (<font color="red">*</font>)
                            </td>
                            <td>
                                <%=Html.DropDownListFor(m=>m.Project.ProjectLegalID, Model.ListLegalStatus, "--Trạng thái pháp lý--", new { @class="required" })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                               Tên dự án (<font color="red">*</font>)
                            </td>
                            <td>
                                <%=Html.TextBoxFor(m=>m.Project.Title, new { style = "width: 500px;", @class="required" })%>
                            </td>
                        </tr>
                        <tr>
							<td class="key">
								Tỉnh/Thành phố (<font color="red">*</font>)
							</td>
							<td>
								<%=Html.DropDownListFor(m=>m.Project.CityID, Model.ListCity, "-- Tỉnh/Thành phố --", new { @class="required" })%>
							</td>
						</tr>
						<tr>
							<td class="key">
								Quận/Huyện (<font color="red">*</font>)
							</td>
							<td>
								<%=Html.DropDownListFor(m=>m.Project.DistrictID, Model.ListDistrict, "-- Quận/Huyện --", new { @class="required" })%>
							</td>
						</tr>
						<tr>
						    <td class="key">Địa chỉ (<font color="red">*</font>)</td>
						    <td><%=Html.TextBoxFor(m => m.Project.Address, new {@class="required", style="width:500px"})%></td>
						</tr>
                        <tr>
                            <td class="key">
                                Tóm tắt (<font color="red">*</font>)
                            </td>
                            <td>
                                <%=Html.TextAreaFor(m => m.Project.Summary, new { cols = 90, rows = 2, @class = "required"})%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Mô tả
                            </td>
                            <td>
                                <%=Html.TextAreaFor(m=>m.Project.ProjectContent, new { cols = 90, rows = 20 })%>
                            </td>
                        </tr>
                        <% if (Model.CompanyType != null && Model.CompanyType.Count() > 0)
                           { %>
                        <tr>
                            <td class="key">
                                Chọn công ty
                            </td>
                            <td>
                                <% 
                                   foreach (var item in Model.CompanyType)
                                   {
                                       var citem = Model.ListProjectCompanyMap.Where(m => m.TypeID == item.ID).FirstOrDefault();
                                       string cid = citem == null ? string.Empty : citem.CompanyID.ToString();
                                       if (!string.IsNullOrEmpty(cid))
                                           Model.ListCompany.SingleOrDefault(c => c.Value == cid).Selected = true;
                                %>
                                <%=Html.DropDownList(Model.CompanyTypeID + item.ID.ToString(), Model.ListCompany, string.Format("--{0}--", item.Name))%>
                                <%
                                    if (!string.IsNullOrEmpty(cid))
                                        Model.ListCompany.SingleOrDefault(c => c.Selected == true).Selected = false;
                                   } %>
                            </td>
                        </tr>
                        <%} %>
                        <tr>
                            <td class="key">
                                Ảnh đại diện
                            </td>
                            <td>
                                <input type="file" name="ImagePaths" id="ImagePaths" />
                            </td>
                        </tr>
                        <tr>
                            <td class="key">Chọn tag</td>
                            <td>
                                <%= Html.TextBox("TagName",Model.CurrentListTag, new { style = "width:350px" })%>
                                <%= Html.Hidden("TagID")%> (<font color="red">*</font>)Cho phép chọn nhiều tag, mỗi tag cách nhau bằng dấu ","
                            </td> 
                        </tr>
                        <%--<tr>
                            <td class="key">
                                Vĩ độ
                            </td>
                            <td>
                                <%=Html.TextBoxFor(m=>m.Project.Longitude, new { style = "width: 100px; text-align: center;" })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Kinh độ
                            </td>
                            <td>
                                <%=Html.TextBoxFor(m=>m.Project.Latitude, new { style = "width: 100px; text-align: center;" })%>
                            </td>
                        </tr>--%>
                        <tr>
                            <td class="key">
                                Quy mô
                            </td>
                            <td>
                                <%=Html.TextBoxFor(m=>m.Project.Scale, new { style = "width: 300px;" })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Vốn đầu tư
                            </td>
                            <td>
                                <%=Html.TextBoxFor(m=>m.Project.Investment, new { style = "width: 300px;" })%> 
                            </td>
                        </tr>
                        <%--<tr>
                            <td class="key">
                                Đơn vị vốn đầu tư
                            </td>
                            <td>
                                <%=Html.TextBoxFor(m=>m.Project.InvestmentUnit, new { style = "width: 300px;" })%>
                            </td>
                        </tr>--%>
                        <tr>
                            <td class="key">
                                Trạng thái hiển thị
                            </td>
                            <td>
                                <%= Html.RadioButtonFor(m => m.Project.PubYN, Model.Project.PubYN)%>
                                Đăng tin
                                <%= Html.RadioButtonFor(m => m.Project.PubYN, !Model.Project.PubYN)%>
                                Không đăng
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Tin HOT?
                            </td>
                            <td>
                                <%= Html.RadioButtonFor(m=>m.Project.HotYN, Model.Project.HotYN)%>
                                Tin hot
                                <%= Html.RadioButtonFor(m=>m.Project.HotYN, !Model.Project.HotYN)%>
                                Tin không hot
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Metadescription
                            </td>
                            <td>
                                <%=Html.TextAreaFor(m=>m.Project.MetaDescription, new { cols = 90, rows = 2 })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Metakeyword
                            </td>
                            <td>
                                <%=Html.TextAreaFor(m=>m.Project.MetaKeyword, new { cols = 90, rows = 2 })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Metatag
                            </td>
                            <td>
                                <%=Html.TextAreaFor(m=>m.Project.MetaTag, new { cols = 90, rows = 2 })%>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center">
                                <input type="hidden" id="Project.InvestmentUnit" name="Project.InvestmentUnit" value="<%= Model.Project.InvestmentUnit %>" />
                                <input type="hidden" id="Project_Longitude" name="Project.Longitude" value="<%= Model.Project.Longitude %>" />
                                <input type="hidden" id="Project_Latitude" name="Project.Latitude" value="<%= Model.Project.Latitude %>" />
                                <input type="hidden" id="Project.AddDate" name="Project.AddDate" value="<%= Model.Project.AddDate %>" />
                                <input type="hidden" id="Project.ImagePath" name="Project.ImagePath" value="<%= Model.Project.ImagePath %>" />
                                <input type="submit" id="btnSave" value="Lưu thay đổi" onclick="return check_extension('ImagePaths','btnSave');" />
                            </td>
                        </tr>
                    </tbody>
                </table>

                <script type="text/javascript">
                	$(document).ready(function() {
                		$("#adminForm").validate();
                		$("#Project_CityID").unbind("change").change(function() {
                			var val = $("#Project_CityID").val();
                			if (val == "" || val == '' || val == undefined)
                				return false;
                			AjaxChange("#Project_CityID", "#Project_DistrictID", "/AjaxData/LoadDistrictByCity/");
                		});
                	});

                    var fileIndex = 1;
                    var hash = { '.jpg': 1, '.png': 1, '.gif': 1, '.doc': 1, '.docx': 1, '.xls': 1, '.xlsx': 1, '.zip': 1, '.rar': 1, '.ppt': 1, '.pptx': 1, '.txt:': 1 };
                    function check_extension(filename, submitId) {
                        var re = /\..+$/;
                        var ext = filename.match(re).toString().toLowerCase();
                        var submitEl = document.getElementById(submitId);
                        if (hash[ext]) {
                            submitEl.disabled = false;
                            return true;
                        } else {
                        }
                    }
                    tinyMCE.init({
                        mode: "exact",
                        elements: "Project_ProjectContent",
                        theme: "advanced",
                        plugins: "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,paste,imagemanager",
                        theme_advanced_buttons1: "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
                        theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
                        theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
                        theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
                        theme_advanced_toolbar_location: "top",
                        theme_advanced_toolbar_align: "left",
                        theme_advanced_statusbar_location: "bottom",
                        paste_use_dialog: false,
                        paste_auto_cleanup_on_paste: true,
                        paste_convert_headers_to_strong: false,
                        paste_strip_class_attributes: "all",
                        paste_remove_spans: true,
                        paste_remove_styles: true
                    });
                </script>

            </div>
            <div id="projectTabs-2">
               <div id="maps" onunload="GUnload()">
                    <style type="text/css">
                        .map
                        {
                            width: 804px;
                            padding: 10px;
                            overflow: hidden;
                        }
                        .map img
                        {
                        }
                        .info
                        {
                            width: 804px;
                            overflow: hidden;
                        }
                        .infoL
                        {
                            float: left;
                            margin: 5px 0 0 0;
                            padding-top: 0px;
                        }
                        .infoL p
                        {
                            font: 12px Arial;
                            color: #0096db;
                            font-weight: bold;
                            margin-top: 0px;
                        }
                        .infoL .note
                        {
                            width: 483px;
                            padding: 7px;
                            height: 50px;
                            background-color: #e8e8e8;
                            overflow: hidden;
                            font: 12px Arial;
                            color: #000000;
                            font-weight: bold;
                            line-height: 16px;
                        }
                        .infoR
                        {
                            float: right;
                            margin: 20px 2px 0 0;
                        }
                        .button1
                        {
                            width: 63px;
                            height: 24px;
                            font: 12px Arial;
                            color: #000000;
                            font-weight: bold;
                            cursor: pointer;
                        }
                        .button2
                        {
                            width: 116px;
                            height: 24px;
                            font: 12px Arial;
                            color: #000000;
                            font-weight: bold;
                            cursor: pointer;
                        }
                    </style>

                    <script type="text/javascript">

                        $(document).ready(function() {
                            $("#googleTabs").click(function() {
                                initialize();
                                showAddress();
                            });
                        });
                    
                    </script>

                    <script src="http://maps.google.com/maps?file=api&amp;v=3&amp;sensor=true&amp;key=<%= Model.GoogleAPI %>"
                        type="text/javascript"></script>

                    <script type="text/javascript">
                        var map = null;
                        var geocoder = null;

                        function initialize() {
                            if (GBrowserIsCompatible()) {
                                map = new GMap2(document.getElementById("map_canvas"));
                                map.setCenter(new GLatLng(21.033, 105.850), 15);
                                map.setUIToDefault();
                                geocoder = new GClientGeocoder();
                                var marker = new GMarker(new GLatLng(21.033, 105.850), { draggable: true });

                                //Draggable marker
                                GEvent.addListener(marker, "dragstart", function() {
                                    map.closeInfoWindow();
                                });
                                GEvent.addListener(marker, "dragend", function() {

                                    //marker.openInfoWindowHtml("aaaaa"+ marker.getLatLng());
                                    document.getElementById("Project_Latitude").value = marker.getLatLng().lat();
                                    document.getElementById("Project_Longitude").value = marker.getLatLng().lng();
                                });
                                map.addOverlay(marker);
                            }
                        }

                        function showAddress() {
                            var lat, lng;
                            lat = document.getElementById("Project_Latitude").value;
                            lng = document.getElementById("Project_Longitude").value;
                            if (lat == '' && lng == '' || lat == 0 && lng == 0) {
                                map.clearOverlays();
                                map.setCenter(new GLatLng(21.033, 105.850), 15);
                                var marker = new GMarker(new GLatLng(21.033, 105.850), { draggable: true });

                                document.getElementById("Project_Latitude").value = marker.getLatLng().lat();
                                document.getElementById("Project_Longitude").value = marker.getLatLng().lng();

                                //Draggable marker
                                GEvent.addListener(marker, "dragstart", function() {
                                    map.closeInfoWindow();
                                });
                                GEvent.addListener(marker, "dragend", function() {
                                    document.getElementById("Project_Latitude").value = marker.getLatLng().lat();
                                    document.getElementById("Project_Longitude").value = marker.getLatLng().lng();
                                });
                                map.addOverlay(marker);
                            }
                            else {
                                map.clearOverlays();
                                map.setCenter(new GLatLng(lat, lng), 15);
                                var marker = new GMarker(new GLatLng(lat, lng), { draggable: true });

                                document.getElementById("Project_Latitude").value = marker.getLatLng().lat();
                                document.getElementById("Project_Longitude").value = marker.getLatLng().lng();

                                //Draggable marker
                                GEvent.addListener(marker, "dragstart", function() {
                                    map.closeInfoWindow();
                                });
                                GEvent.addListener(marker, "dragend", function() {

                                    //marker.openInfoWindowHtml("aaaaa"+ marker.getLatLng());
                                    document.getElementById("Project_Latitude").value = marker.getLatLng().lat();
                                    document.getElementById("Project_Longitude").value = marker.getLatLng().lng();
                                });
                                map.addOverlay(marker);
                            }
                        }
                        function LocationFinished() {
                            //window.opener.document.getElementById("latitude").value = document.getElementById("latitude").value;
                            alert(document.getElementById("Project_Latitude").value);
                            //window.opener.document.getElementById("longitude").value = document.getElementById("longitude").value;
                            document.getElementById("idHoanTat").style.display = "block";
                        }
                        function LocationFinishedClose() {
                            //window.opener.document.getElementById("Project_Latitude").value = document.getElementById("latitude").value;
                            //window.opener.document.getElementById("Project_Longitude").value = document.getElementById("longitude").value;
                            //window.close();
                        }
                    </script>

                    <div class="map">
                        <div id="map_canvas" style="width: 100%; height: 400px; padding-bottom: 10px; position: relative;">
                        </div>
                        <%--<input type="hidden" name="latitude" id="latitude" value="" />
                        <input type="hidden" name="longitude" id="longitude" value="" />--%>
                        <div class="info">
                            <div class="infoL">
                                <p style="display: none" id="idHoanTat">
                                    <img src="../images/ico_map_check.gif" width="22" height="22" alt="" />&nbsp;Vị
                                    trí tài sản đã được cập nhật !</p>
                                <div class="note">
                                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                            <td width="9%">
                                                <img src="/Images/map_quest.gif" width="36" height="44" alt="" />
                                            </td>
                                            <td width="91%">
                                                Sử dụng con trỏ chuột di chuyển icon (<img src="/Images/map_ico.gif" width="12" height="16"
                                                    alt="" />
                                                ) đến vị trí của tài sản trên bản đồ. Nhấn nút “Cập nhật vị trí” để cập nhật vị
                                                trí cho tài sản.
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </div>
                            <div class="infoR">
                                <%--<input type="button" name="cmdFinish" class="button2" id="cmdFinish" value="Cập nhật vị trí"
                                    onclick="LocationFinished();" />&nbsp;
                                <input type="button" name="cmdClose" class="button1" id="cmdClose" value="Đóng lại"
                                    onclick="LocationFinishedClose();" />--%>
                            </div>
                        </div>
                    </div>
                </div>
                
            </div>
            <%} %>
            <div id="projectTabs-3">
                <% using (Html.BeginForm("AddImage", "Project", FormMethod.Post, new
                   {
                       id = "adminForm",
                       enctype = "multipart/form-data"
                   }))
                   {%>
                <%= Html.ValidationSummary(true)%>
                <ul>
                    <% if (Model.ListProjectImage != null && Model.ListProjectImage.Count() > 0)
                       {
                           foreach (var item in Model.ListProjectImage)
                           {
                               if (item.ImageTypeID == 1)
                               {
                    %>
                    <li style="display: inline;">
                        <img width="110" height="75" style="border: 1px solid #CCCCCC;" class="bor_img" alt="" src="<%= Model.ImageRootUrl +"/"+ item.ImageTypeID + "/" + item.ImagePath %>" />
                    </li>
                    <%}
                           }
                       }%>
                </ul>
                <table class="admintable" width="100%">
                    <tbody>
                        <tr>
                            <td class="key">
                                File ảnh phối cảnh
                            </td>
                            <td>
                                <table id="frmFiles" width="100%" class="adminlist">
                                    <tr>
                                        <th>
                                            Ảnh đính kèm:
                                        </th>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input id="fileInput1" size="25" name="fileInput1" type="file" onchange="check_extension(this.value,'btnSave');" />
                                            &nbsp;<input id="btnAddFile" type="button" value="Thêm" onclick="AddFiles();" />
                                        </td>
                                    </tr>
                                </table>

                                <script type="text/javascript">
                                    var fileIndex = 1;
                                    var hash = { '.jpg': 1, '.png': 1, '.gif': 1, '.doc': 1, '.docx': 1, '.xls': 1, '.xlsx': 1, '.zip': 1, '.rar': 1, '.ppt': 1, '.pptx': 1, '.txt:': 1 };
                                    function check_extension(filename, submitId) {
                                        var re = /\..+$/;
                                        var ext = filename.match(re).toString().toLowerCase();
                                        var submitEl = document.getElementById(submitId);
                                        if (hash[ext]) {
                                            submitEl.disabled = false;
                                            return true;
                                        } else {
                                        }
                                    };
                                    function AddFiles() {
                                        fileIndex++;
                                        var tag = "<td><input id='fileInput" + fileIndex.toString() + "' name='fileInput" + fileIndex.toString() + "' type=\"file\" size='25'  onchange=\"check_extension(this.value,'btnSave');\" /></td>";
                                        var row = "<tr>" + tag + "</tr>";
                                        $("#frmFiles").append(row);
                                    };
                                </script>

                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center">
                                <input type="hidden" id="ImageTypeID" name="ImageTypeID" value="1" />
                                <input type="hidden" id="ProjectID" name="ProjectID" value="<%= Model.Project.ID %>" />
                                <input type="submit" id="Submit1" value="Thêm mới" onclick="return check_extension('ArticleImage','btnSave');" />
                            </td>
                        </tr>
                    </tbody>
                </table>
                <%} %>
            </div>
            <div id="projectTabs-4">
                <% using (Html.BeginForm("AddImage", "Project", FormMethod.Post, new
                   {
                       id = "adminForm",
                       enctype = "multipart/form-data"
                   }))
                   {%>
                <%= Html.ValidationSummary(true)%>
                <ul>
                    <% if (Model.ListProjectImage != null && Model.ListProjectImage.Count() > 0)
                       {
                           foreach (var item in Model.ListProjectImage)
                           {
                               if (item.ImageTypeID == 2)
                               {
                    %>
                    <li style="display: inline;">
                        <img width="110" height="75" style="border: 1px solid #CCCCCC;" class="bor_img" alt="" src="<%= Model.ImageRootUrl +"/"+ item.ImageTypeID + "/" + item.ImagePath %>" />
                    </li>
                    <%}
                           }
                       }%>
                </ul>
                <table class="admintable" width="100%">
                    <tbody>
                        <tr>
                            <td class="key">
                                File ảnh tiến độ
                            </td>
                            <td>
                                <table id="frmFile1" width="100%" class="adminlist">
                                    <tr>
                                        <th>
                                            Ảnh đính kèm:
                                        </th>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input id="fileInput1" size="25" name="fileInput1" type="file" onchange="check_extension(this.value,'btnSave');" />
                                            &nbsp;<input id="Button1" type="button" value="Thêm" onclick="AddFile1();" />
                                        </td>
                                    </tr>
                                </table>

                                <script type="text/javascript">
                                    var fileIndex = 1;
                                    var hash = { '.jpg': 1, '.png': 1, '.gif': 1, '.doc': 1, '.docx': 1, '.xls': 1, '.xlsx': 1, '.zip': 1, '.rar': 1, '.ppt': 1, '.pptx': 1, '.txt:': 1 };
                                    function check_extension(filename, submitId) {
                                        var re = /\..+$/;
                                        var ext = filename.match(re).toString().toLowerCase();
                                        var submitEl = document.getElementById(submitId);
                                        if (hash[ext]) {
                                            submitEl.disabled = false;
                                            return true;
                                        } else {
                                        }
                                    };
                                    function AddFile1() {
                                        fileIndex++;
                                        var tag = "<td><input id='fileInput" + fileIndex.toString() + "' name='fileInput" + fileIndex.toString() + "' type=\"file\" size='25'  onchange=\"check_extension(this.value,'btnSave');\" /></td>";
                                        var row = "<tr>" + tag + "</tr>";
                                        $("#frmFile1").append(row);
                                    };
                                </script>

                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center">
                                <input type="hidden" id="ImageTypeID" name="ImageTypeID" value="2" />
                                <input type="hidden" id="ProjectID" name="ProjectID" value="<%= Model.Project.ID %>" />
                                <input type="submit" id="Submit2" value="Thêm mới" onclick="return check_extension('ArticleImage','btnSave');" />
                            </td>
                        </tr>
                    </tbody>
                </table>
                <%} %>
            </div>
            <div id="projectTabs-5">
                <% using (Html.BeginForm("AddImage", "Project", FormMethod.Post, new
                   {
                       id = "adminForm",
                       enctype = "multipart/form-data"
                   }))
                   {%>
                <%= Html.ValidationSummary(true)%>
                <ul>
                    <% if (Model.ListProjectImage != null && Model.ListProjectImage.Count() > 0)
                       {
                           foreach (var item in Model.ListProjectImage)
                           {
                               if (item.ImageTypeID == 3)
                               {
                    %>
                    <li style="display: inline;">
                        <img width="110" height="75" style="border: 1px solid #CCCCCC;" class="bor_img" alt="" src="<%= Model.ImageRootUrl +"/"+ item.ImageTypeID + "/" + item.ImagePath %>" />
                    </li>
                    <%}
                           }
                       }%>
                </ul>
                <table class="admintable" width="100%">
                    <tbody>
                        <tr>
                            <td class="key">
                                Ảnh nhà mẫu

                            </td>
                            <td>
                                <table id="frmFile2" width="100%" class="adminlist">
                                    <tr>
                                        <th>
                                            Ảnh đính kèm:
                                        </th>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input id="fileInput1" size="25" name="fileInput1" type="file" onchange="check_extension(this.value,'btnSave');" />
                                            &nbsp;<input id="Button2" type="button" value="Thêm" onclick="AddFile2();" />
                                        </td>
                                    </tr>
                                </table>

                                <script type="text/javascript">
                                    var fileIndex = 1;
                                    var hash = { '.jpg': 1, '.png': 1, '.gif': 1, '.doc': 1, '.docx': 1, '.xls': 1, '.xlsx': 1, '.zip': 1, '.rar': 1, '.ppt': 1, '.pptx': 1, '.txt:': 1 };
                                    function check_extension(filename, submitId) {
                                        var re = /\..+$/;
                                        var ext = filename.match(re).toString().toLowerCase();
                                        var submitEl = document.getElementById(submitId);
                                        if (hash[ext]) {
                                            submitEl.disabled = false;
                                            return true;
                                        } else {
                                        }
                                    };
                                    function AddFile2() {
                                        fileIndex++;
                                        var tag = "<td><input id='fileInput" + fileIndex.toString() + "' name='fileInput" + fileIndex.toString() + "' type=\"file\" size='25'  onchange=\"check_extension(this.value,'btnSave');\" /></td>";
                                        var row = "<tr>" + tag + "</tr>";
                                        $("#frmFile2").append(row);
                                    };
                                </script>

                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center">
                                <input type="hidden" id="ImageTypeID" name="ImageTypeID" value="3" />
                                <input type="hidden" id="ProjectID" name="ProjectID" value="<%= Model.Project.ID %>" />
                                <input type="submit" id="Submit3" value="Thêm mới" onclick="return check_extension('ArticleImage','btnSave');" />
                            </td>
                        </tr>
                    </tbody>
                </table>
                <%} %>
            </div>
            <div id="projectTabs-6">
                <% using (Html.BeginForm("AddImage", "Project", FormMethod.Post, new
                   {
                       id = "adminForm",
                       enctype = "multipart/form-data"
                   }))
                   {%>
                <%= Html.ValidationSummary(true)%>
                <ul>
                    <% if (Model.ListProjectImage != null && Model.ListProjectImage.Count() > 0)
                       {
                           foreach (var item in Model.ListProjectImage)
                           {
                               if (item.ImageTypeID == 4)
                               {
                    %>
                    <li style="display: inline;">
                        <img width="110" height="75" style="border: 1px solid #CCCCCC;" class="bor_img" alt=""
                            src="<%= Model.ImageRootUrl +"/" + item.ImageTypeID + "/" + item.ImagePath %>" />
                    </li>
                    <%}
                           }
                       }%>
                </ul>
                <table class="admintable" width="100%">
                    <tbody>
                        <tr>
                            <td class="key">
                                Sơ đồ bản vẽ
                            </td>
                            <td>
                                <table id="frmFile3" width="100%" class="adminlist">
                                    <tr>
                                        <th>
                                            Ảnh đính kèm:
                                        </th>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input id="fileInput1" size="25" name="fileInput1" type="file" onchange="check_extension(this.value,'btnSave');" />
                                            &nbsp;<input id="Button3" type="button" value="Thêm" onclick="AddFile3();" />
                                        </td>
                                    </tr>
                                </table>

                                <script type="text/javascript">
                                    var fileIndex = 1;
                                    var hash = { '.jpg': 1, '.png': 1, '.gif': 1, '.doc': 1, '.docx': 1, '.xls': 1, '.xlsx': 1, '.zip': 1, '.rar': 1, '.ppt': 1, '.pptx': 1, '.txt:': 1 };
                                    function check_extension(filename, submitId) {
                                        var re = /\..+$/;
                                        var ext = filename.match(re).toString().toLowerCase();
                                        var submitEl = document.getElementById(submitId);
                                        if (hash[ext]) {
                                            submitEl.disabled = false;
                                            return true;
                                        } else {
                                        }
                                    };
                                    function AddFile3() {
                                        fileIndex++;
                                        var tag = "<td><input id='fileInput" + fileIndex.toString() + "' name='fileInput" + fileIndex.toString() + "' type=\"file\" size='25'  onchange=\"check_extension(this.value,'btnSave');\" /></td>";
                                        var row = "<tr>" + tag + "</tr>";
                                        $("#frmFile3").append(row);
                                    };
                                </script>

                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center">
                                <input type="hidden" id="ImageTypeID" name="ImageTypeID" value="4" />
                                <input type="hidden" id="ProjectID" name="ProjectID" value="<%= Model.Project.ID %>" />
                                <input type="submit" id="Submit4" value="Thêm mới" onclick="return check_extension('ArticleImage','btnSave');" />
                            </td>
                        </tr>
                    </tbody>
                </table>
                <%} %>
            </div>
        </div>
    </div>
    <%}%>
    <script type="text/javascript">
        // Start Load du lieu Autocomplete for filed Select tag: Created by Vietlv//
        $("#TagName").autocomplete({
            minLength: 2,
            source: function(request, response) {
                $.ajax({
                    url: "/AjaxData/SearchTag",
                    dataType: "json",
                    data: {
                        keyword: extractLast(request.term)
                    },
                    success: function(data) {
                        response($.map(data, function(item) {
                            return {
                                label: item.Keyword,
                                value: item.Keyword,
                                id: item.ID
                            }
                        }));
                    }
                });
            },
            focus: function() {
                // prevent value inserted on focus
                return false;
            },
            select: function(event, ui) {
                var terms = split(this.value);
                // remove the current input
                terms.pop();
                // add the selected item
                terms.push(ui.item.value);
                // add placeholder to get the comma-and-space at the end
                terms.push("");
                this.value = terms.join(", ");

                var termsk = split($('#TagID').val());
                // remove the current input
                termsk.pop();
                // add the selected item
                termsk.push(ui.item.id);
                // add placeholder to get the comma-and-space at the end
                termsk.push("");
                $('#TagID').val(termsk.join(","));
                return false;
            }
        });
        // end
        // Start Addnew tag
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
    <td>
    <%= Html.Toolbar("Quay lại", "/Project", "back") %>
    </td>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
    Sửa dự án
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Message" runat="server">
    <%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>
</asp:Content>
